<?php

class ContentPeer extends BaseContentPeer
{
    public static function retrieveByTitle( $title ) {
        $c = new Criteria();
        $c->add ( ContentI18nPeer::TITLE , $title ) ;
        $content = ContentI18nPeer::doSelectOne( $c ) ;
        return $content ? $content->getContent() : null;
    }
    public static function getNewsItems( $limit = 20) {
        $c = new Criteria();
        $c->add ( self::CATEGORY_ID , globals::CATEGORY_NEWS ) ;
        $c->setLimit($limit);

        return self::doSelect($c);
    }


    public static function doSelect(Criteria $criteria, PropelPDO $con = null){
        if($criteria){
            //$criteria->addJoin(ContentPeer::ID ,ContentI18nPeer::ID );
            //$criteria->addAscendingOrderByColumn(ContentI18nPeer::TITLE );
        }
        return parent::doSelect( $criteria , $con );
    }

    static public function doSelectOrderByI18nName($c){
        //$c= new Criteria();
        $c->addJoin(self::ID, ContentI18nPeer::ID);
        $c->addAscendingOrderByColumn( ContentI18nPeer::TITLE );
        $c->setDistinct();


        return self::doSelect($c);
    }

}
